feat(user): add consent expiration field to user apis#738
feat(user): add consent expiration field to user apis#738
Conversation
Coverage reportThe coverage rate went from
Diff Coverage details (click to unfold)descope/management/user.py
|
There was a problem hiding this comment.
Pull request overview
This PR adds support for exposing the consent_expiration field in User APIs to track user impersonation consent expiration times. The field represents a Unix timestamp in seconds indicating when a user's consent for impersonation expires.
Key changes:
- Added
consent_expirationparameter toUserObjclass for use in batch operations - Updated patch batch functionality to include the field in API requests when provided
- Added comprehensive test coverage for the new field
- Documented the feature with usage examples in README
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| descope/management/user.py | Added consent_expiration parameter to UserObj, updated _compose_patch_body and _compose_patch_batch_body to handle the field; includes unrelated formatting improvements to update_email and update_phone methods |
| tests/management/test_user.py | Added test_patch_batch_with_consent_expiration test verifying the field is correctly passed through to API requests and properly omitted when not provided |
| README.md | Added "User Impersonation Consent" section documenting the field's availability in API responses and its usage with UserObj for batch operations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| login_id="desmond@descope.com", | ||
| email="desmond@descope.com", | ||
| consent_expiration=1735689600, # Optional Unix timestamp | ||
| ) |
There was a problem hiding this comment.
The UserObj example creates an object but doesn't show how to use it. Consider completing the example by adding a line that shows how to use this object with patch_batch, such as: descope_client.mgmt.user.patch_batch([user_obj])
| ) | |
| ) | |
| descope_client.mgmt.user.patch_batch([user_obj]) |
| sso_app_ids: Optional[List[str]], | ||
| status: Optional[str], | ||
| test: bool = False, | ||
| consent_expiration: Optional[int] = None, |
There was a problem hiding this comment.
The consent_expiration parameter was added to _compose_patch_body, but the patch method that calls this function doesn't accept or pass this parameter. This creates an API design inconsistency: users can set consent_expiration via patch_batch with UserObj, but cannot use the individual patch method. The status field follows the pattern of being available in both patch and patch_batch. Consider adding consent_expiration as a parameter to the patch method and passing it through to _compose_patch_body.
Fixes descope/etc#13531
View workflow run
Perfect! Now let me create a final verification summary:
Implementation Complete ✅
I have successfully implemented the consent expiration field exposure in the Descope Python SDK User APIs. Here's what was done:
Changes Made:
1. descope/management/user.py
consent_expiration: Optional[int]parameter toUserObj.__init__()self.consent_expirationinstance variable_compose_patch_body()to includeconsent_expirationparameter"consentExpiration"in the request body when provided_compose_patch_batch_body()to passuser.consent_expiration2. tests/management/test_user.py
test_patch_batch_with_consent_expiration()3. README.md
Technical Details:
Optional[int](Unix timestamp in seconds)consentExpiration(camelCase - API convention)consent_expiration(snake_case - Python convention)None(fully optional field)How Users Can Use This:
Verification:
The implementation is complete and ready for the CI pipeline to handle git operations! 🎉
Created by Shuni 🐕